<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<link rel="stylesheet" href="<?=LAY_PATH?>css/layui.css">

<div class="pad-lr-10">
    <form class="layui-form" id="form" method="post" enctype="multipart/form-data" onsubmit="return postdata()" action="index.php?m=webman&c=banner&a=action&pc_hash=<?=$_SESSION['pc_hash']?>">
<table class="layui-table">
    <thead>
    <tr>
        <td style="width: 80px">排序(listid)</td>
        <td>位置(posid)</td>
        <td>标题(title)</td>
        <td>链接(url)</td>
        <td>轮播图(src)</td>
        <td>操作</td>
    </tr>

    </thead>
    <tbody>
    <?php foreach($data as $k=>$v){?>
    <tr id="<?=$v['id']?>">
        <td><input value="<?=$v['listid']?>" type="text" style="text-align: center" class="layui-input listorder"></td>
        <td style="width: 100px;text-align: center"><?php if($v['posid']==0){echo "首页";}else if($v['posid']==1){echo "内页";}?></td>
        <td style="width: 200px;text-align: center"><?=$v['title']?></td>
        <td style="width: 200px;text-align: center"><?=$v['url']?></td>
        <td style="text-align: center"><img src="<?=$v['src']?>" width="190" height="69" alt=""></td>
        <td><button type="button" class="layui-btn layui-btn-sm edit" onclick="edit(<?=$v['id']?>)" style="background: #2f4050;color:#fff">修改</button> | <button type="button" style="background: #2f4050;color:#fff" class="layui-btn layui-btn-sm" onclick="del(<?=$v['id']?>)">删除</button></td>
    </tr>
<?php }?>
    </tbody>


</table>
    </form>
    <div style="width: 120px;margin:auto">
        <button style="background: #2f4050;color:#fff" class="layui-btn add">添加轮播图</button>
    </div>
    


</div>
<script src="<?=LAY_PATH?>layui.js"></script>
<script>

    layui.use(['layer','form'],function(){
      $(".add").click(function(){
          $(".add").css("display","none")
          if($("td").hasClass("edit_c")){
              layer.msg("请先完成图片上传操作或者取消",{icon:2})
          }else {
              $.ajax({
                  url: "index.php?m=webman&c=banner&a=add&pc_hash=<?=$_SESSION['pc_hash']?>",
                  type: "post",
                  success: function (msg) {
                      $('tbody').append(msg)
                  }
              })

          }
      })
    })

</script>

<script type="text/javascript">

  /*phpcms函数，窗口撑开*/
    function test_spider(id) {
        window.top.art.dialog({id:'test'}).close();
        window.top.art.dialog({title:'<?php echo L('data_acquisition_testdat')?>',id:'test',iframe:'?m=collection&c=node&a=public_test&nodeid='+id,width:'700',height:'500'}, '', function(){window.top.art.dialog({id:'test'}).close()});
    }

    function copy_spider(id) {
        window.top.art.dialog({id:'test'}).close();
        window.top.art.dialog({title:'<?php echo L('copy_node')?>',id:'test',iframe:'?m=collection&c=node&a=copy&nodeid='+id,width:'420',height:'120'}, function(){var d = window.top.art.dialog({id:'test'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'test'}).close()});
    }

    function import_spider() {
        window.top.art.dialog({id:'test'}).close();
        window.top.art.dialog({title:'<?php echo L('import_collection_points')?>',id:'test',iframe:'?m=collection&c=node&a=node_import',width:'420',height:'200'}, function(){var d = window.top.art.dialog({id:'test'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'test'}).close()});
    }
  /*phpcms函数，窗口撑开*/

  /*临时图片显示函数*/
    function preview(file)
    {
        var prevDiv = document.getElementById('preview');
        if (file.files && file.files[0])
        {
            var reader = new FileReader();
            reader.onload = function(evt){
                prevDiv.innerHTML = '<img src="' + evt.target.result + '" height="80" width="300"  />';
            };
            reader.readAsDataURL(file.files[0]);
        }
        else
        {
            prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
        }
    }

    window.top.$('#display_center_id').css('display','none');
    //-->
  /*ajax删除*/
  function del(id){
      layer.confirm('确定删除吗？', {
          btn: ['确定', '取消'] //可以无限个按钮
      }, function(index, layero){
          $.post("index.php?m=webman&c=banner&a=del&pc_hash=<?=$_SESSION['pc_hash']?>", {id: id}, function (msg) {
              if (msg == "ok") {
                  layer.msg('删除成功', {icon: 1}, function () {
                      location.reload();
                  })
              }
          })
      }, function(index){
      
      });
  }


  function edit(id){
      $(".add").css("display","none")
      $.post("index.php?m=webman&c=banner&a=edit&pc_hash=<?=$_SESSION['pc_hash']?>",{id:id},function (msg) {
       $("#"+id).html(msg)
      });
  }


</script>
<script>



    layui.use(['layer','form','upload','jquery'], function(){
        var form = layui.form;  var layer = layui.layer;
        var $ = layui.jquery
            ,upload = layui.upload;




    });

</script>
</body>
</html>